{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/backspace-string-compare\n",
    "\n",
    "\n",
    "\n",
    "Runtime: 0 ms, faster than 100.00% of C++ online submissions for Backspace String Compare.\n",
    "Memory Usage: 6.6 MB, less than 43.38% of C++ online submissions for Backspace String Compare.\n",
    "\n",
    "\n",
    "\n",
    "```cpp\n",
    "#include <iostream>\n",
    "#include <string.h>\n",
    "\n",
    "using namespace std;\n",
    "\n",
    "class Solution\n",
    "{\n",
    "public:\n",
    "    bool backspaceCompare(string S, string T)\n",
    "    {\n",
    "        //cout << \"s: \" << this->inputBox(S) << endl;\n",
    "        //cout << \"t: \" << this->inputBox(T) << endl;\n",
    "        return this->inputBox(S) == this->inputBox(T);\n",
    "    }\n",
    "\n",
    "    string inputBox(string S)\n",
    "    {\n",
    "        string r = \"\";\n",
    "        for (int i = 0; i < S.size(); i++)\n",
    "        {\n",
    "            auto c = S[i];\n",
    "            if (c == '#')\n",
    "            {\n",
    "                if (r.size() > 0)\n",
    "                {\n",
    "                    r.erase(r.size() - 1, 1);\n",
    "                }\n",
    "            }\n",
    "            else\n",
    "            {\n",
    "                r.push_back(c);\n",
    "            }\n",
    "        }\n",
    "        return r;\n",
    "    }\n",
    "};\n",
    "\n",
    "int main(int argc, char *argv[])\n",
    "{\n",
    "    auto s = Solution();\n",
    "    auto r = s.backspaceCompare(\"ab##d\", \"ad##d\");\n",
    "    cout << \"result: \" << r << endl;\n",
    "    return 0;\n",
    "}\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C++17",
   "language": "C++17",
   "name": "xcpp17"
  },
  "language_info": {
   "codemirror_mode": "text/x-c++src",
   "file_extension": ".cpp",
   "mimetype": "text/x-c++src",
   "name": "c++",
   "version": "17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
